from omegaconf import OmegaConf

def add_to_sh(name):
    sh_file_path = '/cpfs01/user/feiben/texture/TEXTurePaper/sh_11_26.sh'
    with open(sh_file_path, 'a') as file:
        file.write(f'python -m scripts.run_texture --config_path=configs/text_guided/{name}.yaml')
        file.write('\n')
# 将这些路径替换为您的实际文件路径
input_yaml_path = '/cpfs01/user/feiben/texture/TEXTurePaper/configs/text_guided/nascar_overlap_img_x0_DDPM_view2_step20_range0.yaml'


# 使用Omegaconf加载YAML文件
config = OmegaConf.load(input_yaml_path)

# for _step in range(30, 60, 10):
# for _range in range(30, 50, 5):
    # 修改数据
_range = 40
_step = 50
_loss_type = 'l1'
config.optim.update_step = _step
config.optim.overlap_range = _range
config.optim.loss_type = _loss_type
config.log.exp_name = f'nascar_overlap_img_x0_DDPM_view2_step{config.optim.update_step}_range{config.optim.overlap_range}_loss:{_loss_type}'
output_yaml_path = f'/cpfs01/user/feiben/texture/TEXTurePaper/configs/text_guided/{config.log.exp_name}.yaml'
# 保存修改后的YAML文件
with open(output_yaml_path, 'w') as file:
    OmegaConf.save(config=config, f=file)
add_to_sh(config.log.exp_name)


    


